package com.learing.handler.realChat;

import com.learing.message.MessageResponsePacket;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

import java.util.Date;

public class MessageResponseHandler extends SimpleChannelInboundHandler<MessageResponsePacket> {
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, MessageResponsePacket messageResponsePacket) {
         receiveMessage(messageResponsePacket,ctx);
    }

    private MessageResponsePacket receiveMessage(MessageResponsePacket messageResponsePacket, ChannelHandlerContext ctx) {
        String fromUserId = messageResponsePacket.getFromUserId();
        String fromUserName = messageResponsePacket.getFromUserName();
        System.out.println(fromUserId + ":" + fromUserName + " -> " + messageResponsePacket .getMessage());
        return messageResponsePacket;
    }
}